package org.example.test.domain.strategy;

import lombok.extern.slf4j.Slf4j;
import org.example.domain.strategy.model.entity.RaffleAwardEntity;
import org.example.domain.strategy.model.entity.RaffleFactorEntity;
import org.example.domain.strategy.service.IRaffleStrategy;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.concurrent.CountDownLatch;

/**
 * @Author: PengHao
 * @CreateTime: 2025-07-13  21:13
 * @Description: TODO
 */
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class StrategyRafferTset {

    @Resource
    private IRaffleStrategy raffleStrategy;

    @Test
    public void raffleByStrategyId(){
        RaffleFactorEntity raffleFactorEntity = RaffleFactorEntity.builder()
                .strategyId(100003L)
                .userId("user004")
                .build();
        RaffleAwardEntity raffleAwardEntity = raffleStrategy.performRaffle(raffleFactorEntity);
        System.out.println(raffleAwardEntity);

    }


    @Test
    public void raffleTimesByStrategyId() throws InterruptedException {
        for (int i = 0; i < 3; i++) {
            RaffleFactorEntity raffleFactorEntity = RaffleFactorEntity.builder()
                    .strategyId(100003L)
                    .userId("user004")
                    .build();
            RaffleAwardEntity raffleAwardEntity = raffleStrategy.performRaffle(raffleFactorEntity);
            System.out.println(raffleAwardEntity);
        }
        new CountDownLatch(1).await();
    }

}
